
data = [[1,2,3],
        [4,5,6],
        [7,8,9]]

#%% 顺时针旋转   ： 倒序 -> 转置
#倒序
data = data[::-1]
#转置
for i in range(len(data)):
    for j in range(i,len(data)):
        data[i][j],data[j][i] = data[j][i],data[i][j]

#%% 逆时针旋转   ：  转置 -> 倒序
#转置
for i in range(len(data)):
    for j in range(i,len(data)):
        data[i][j],data[j][i] = data[j][i],data[i][j]
#倒序
data = data[::-1]